A number is considered good if
it consists only of odd digits. For example, the number 157953 is good, while the number 2452117 is not. Determine how many n-digit good numbers exist.
Input. One positive integer n (1 ≤ n ≤ 20).
Output. Print the number of n-digit good numbers.
|
Sample input |
Sample output |
|
4 |
625 |
combinatorics
Algorithm analysis
There are
five odd digits in total: 1, 3, 5, 7 and 9. Each
of these digits can occupy any position in an n-digit number. Since each
of the n positions can contain one of the five digits, the total number
of good numbers is 5n.
Algorithm implementation
Read the input value of n.
scanf("%d",&n);
Сompute the number of n-digit good numbers in
the variable res.
res = 1;
for(i = 0; i < n; i++)
res *= 5;
Print the answer.
printf("%lld\n",res);